package TestPackage;

import DataSetPackage.SimpleView;
import DataSetPackage.View;
import EstimatorPackage.AbstractEstimatorExp;
import EstimatorPackage.EstimatorExp;
import HierarchyPackage.HClass;
import HierarchyPackage.Hierarchy;
import HierarchyPackage.SimpleHierarchy.SimpleHClass;
import HierarchyPackage.SimpleHierarchy.SimpleHierarchy;

/**
 *
 * @author Martin Haulrich
 */
public class SimPOSEstimatorExp extends AbstractEstimatorExp implements EstimatorExp {

//    final static String STOP = "$";
//
//    final static String START = "^";
    final EmpPOS est;

    SimpleHierarchy hier;

    public SimPOSEstimatorExp(EmpPOS est, SimpleHierarchy hier) {
        super();
        this.est = est;
        this.hier = hier;


    }

    @Override
    public double getEstimate(Integer did, View v) {
        //    double estimate = est.getEstimate(START + ((SimpleView) v).getFeatures(did)[0] + STOP);
        double estimate = est.getEstimate(((SimpleView) v).getFeature(did));
        //  System.err.println("SufEstExp: " + did + " : " + START + ((SimpleView) v).getFeatures(did)[0] + STOP +  "  = " + estimate);
        return estimate;
    }

    @Override
    public double getEstimate(HClass h, Hierarchy hier) {

        if (h.equals(hier.getTop())) {
            return 0;
        }

        SimpleHClass sh = (SimpleHClass) h;

        /**
         * @TODO Using the name - that is ugly
         */
        return est.getEstimate(sh.getName());

    }
}

